using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Office = Microsoft.Office.Core;
using System.Drawing;
using LogAnalyzerIIS.Properties;
using System.Resources;

namespace LogAnalyzerIIS
{
	public partial class ThisAddIn
	{
		private LogAnalyzerIISRibbon ribbon;

		protected override object RequestService(Guid serviceGuid)
		{
			if (serviceGuid == typeof(Office.IRibbonExtensibility).GUID)
			{
				if (ribbon == null)
					ribbon = new LogAnalyzerIISRibbon();
				return ribbon;
			}

			return base.RequestService(serviceGuid);
		}
	}

	[ComVisible(true)]
	public class LogAnalyzerIISRibbon : Office.IRibbonExtensibility
	{
		private SideBar sideBar;
		Microsoft.Office.Tools.CustomTaskPane customTaskPane;

		private Office.IRibbonUI ribbon;

		public LogAnalyzerIISRibbon()
		{
			sideBar = new SideBar();
			sideBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
			customTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(sideBar, "Log Analyzer");

			customTaskPane.VisibleChanged += new EventHandler(ctp_VisibleChanged);
		}

		private void ctp_VisibleChanged(object sender, EventArgs e)
		{

		}

		#region IRibbonExtensibility Members

		public string GetCustomUI(string ribbonID)
		{
			return Resources.LogAnalyzerIISRibbon;
		}

		#endregion

		#region Ribbon Callbacks

		public void OnLoad(Office.IRibbonUI ribbonUI)
		{
			this.ribbon = ribbonUI;
		}

		public void OnToggleButton1(Office.IRibbonControl control)
		{
			customTaskPane.Visible = !customTaskPane.Visible;
		}

		public Bitmap LoadImage(string imageName)
		{
			object obj = Resources.ResourceManager.GetObject(imageName);
			return ((System.Drawing.Bitmap)(obj));
		}
		#endregion
	}
}
